#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QWidget>
#include <QTimer>
#include <ctime>

#include "config.h"
#include "map.h"
#include "heroplane.h"
#include "bullet.h"
#include "enemyplaneh.h"
#include <ctime>
#include "config.h"
#include "light.h"
#include "levelplane.h"
#include "bomb.h"
#include  "plane.h"
#include "enemybullet.h"
//#include <QSound>
#include "ranklogin.h"
#include "rankdialog.h"


//This is the window for playing
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{    
signals:
    void SignalSetRecord(QString);

private slots:
    void on_pushButton_clicked();

    void on_StopButton_clicked();

private:
    Ui::MainWindow *ui;
    Q_OBJECT

    int click_count=0;

    //window objects
    QWidget *sf1;
    RankLogin *sf2;
    RankDialog *sf3 = new RankDialog();

    //地图对象
    map m_map;
    //飞机对象
    HeroPlane m_hero;
    Levelplane m_level;


//    //升级的飞P机对象指针
//    m_heroptr->delete;
//    m_heroptr= new Levelplane());
    //定时器
    QTimer m_Timer;

    //绘制到屏幕中  函数名称不可改变
    void paintEvent(QPaintEvent *);

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    //初始化场景
    void initSence();

    //启动游戏
    void playGame();

    //更新所有游戏中元素的坐标
    void updatePosition();

    //Key board control
    virtual void keyPressEvent(QKeyEvent *ev);

    //overBoundDetect
    void overBoundDetect(int &x, int &y,int w,int h);

    //声明碰撞
    void collisionDetection();

    //敌机出场
    void enemyToWindow();
    //飞机升级
    void levelup();

    //敌机数组
     enemyplane m_enemys[ENEMY_NUM];


     //敌机出场间隔记录
     int m_recorder;

    //击杀敌人数量
      static int dead;

     void levelcollisionDetection();

     //爆炸数组
     bomb m_bombs[BOMB_NUM];

     //飞机发光
     void shine();

    //无尽模式配置数据的改变
     void change();

     //发光数组
       light m_lights[LIGHT_NUM];


     //game status
     bool ifStop = false;
};

#endif // MAINWINDOW_H
